package com.heaven.customerServer.customerController;

import com.heaven.customerServer.customerController.vo.login.LoginRes;
import com.heaven.customerServer.customerController.vo.user.UserInfoRes;
import com.heaven.service.UserService;
import com.heaven.utils.R;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("heaven-server/user")
public class UserController {
    @Resource
    private UserService userService;
    @Resource
    private LoginController loginController;

    @GetMapping("/get-userinfo")
    public R getUserInfo(@RequestParam("userId") String userId){
        LoginRes.UserSession session = loginController.getUserSession();
        UserInfoRes ans = userService.getUserInfo(userId, session);
        return R.okData(ans);
    }

    /**
     * 订阅/取消订阅
     */
    @RequestMapping("/auth/subscribe")
    public R getSubscribedList(@RequestParam("id") String id,
                               @RequestParam("type") int type){
        LoginRes.UserSession session = loginController.getUserSession();
        userService.subscribe(id, session, type);
        return R.ok();
    }
}
